package com.zhaoxi.project.wms.controller;

import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.project.wms.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

// * 样例信息操作处理
@RestController
@RequestMapping("/wms/warehouse")
public class WarehouseController extends BaseService {
  @Autowired
  private WarehouseService warehouseService;

  // 获分页列表
  @PreAuthorize("@ss.hasPermi('wms:warehouse:list')")
  @GetMapping("/getPage")
  public PageData getPage(Map map) {
    PageData pd = this.getPageData(map);
    startPage();
    return warehouseService.getList(pd);
  }

  //  获列表
  @PreAuthorize("@ss.hasPermi('wms:warehouse:list')")
  @GetMapping("/getList")
  public PageData getList(Map map) {
    PageData pd = this.getPageData(map);
    return warehouseService.getList(pd);
  }

  //  获行数
  @PreAuthorize("@ss.hasPermi('wms:warehouse:list')")
  @GetMapping("/getCount")
  public PageData getCount(Map map) {
    PageData pd = this.getPageData(map);
    return warehouseService.getCount(pd);
  }

  //  新增
  @PreAuthorize("@ss.hasPermi('wms:warehouse:add')")
  @Log(title = "样例管理", businessType = BusinessType.INSERT)
  @PostMapping
  public PageData add(@RequestBody Map map) {
    PageData pd = this.getPageData(map);
    return warehouseService.add(pd);
  }

  //  修改
  @PreAuthorize("@ss.hasPermi('wms:warehouse:edit')")
  @Log(title = "样例管理", businessType = BusinessType.UPDATE)
  @PutMapping
  public PageData edit(@RequestBody Map map) {
    PageData pd = this.getPageData(map);
    return warehouseService.edit(pd);
  }

  //  删除
  @PreAuthorize("@ss.hasPermi('wms:warehouse:del')")
  @Log(title = "样例管理", businessType = BusinessType.DELETE)
  @DeleteMapping("id/{id}")
  public PageData del(@PathVariable Long id) {
    return warehouseService.del(id);
  }
}
